//
//  ST_TianPrivacyView.swift
//  btvideo
//
//  Created by Jason on 2021/9/26.
//  Copyright © 2021 JarvanZhang. All rights reserved.
//

import UIKit
import SwifterSwift


class ST_TianPrivacyView: UIView {
    
    
//     194  17
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.addSubview(notiLabel)
        notiLabel.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
            make.width.equalTo(230)
            make.height.equalTo(17)
        }
        
        self.addSubview(btn2)
        btn2.snp.makeConstraints { (make) in
            make.right.top.bottom.equalTo(notiLabel)
            make.width.equalTo(70)
        }
        
        self.addSubview(btn1)
        btn1.snp.makeConstraints { (make) in
            make.top.bottom.equalTo(notiLabel)
            make.width.equalTo(70)
            make.right.equalTo(btn2.snp.left).offset(-5)
        }
        
        let attrString = NSMutableAttributedString(string: "我已阅读并同意“用户协议”和“隐私政策”")
  
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 12),.foregroundColor: UIColor.init(hex: 0xACB4C0)!]

        attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length))
        
        notiLabel.attributedText = attrString
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
    fileprivate lazy var btn1:UIButton = {
        
        let control = UIButton.init(type: UIButton.ButtonType.custom)
        
        control.addTarget(self, action: #selector(btn1Action), for: UIControl.Event.touchUpInside)
        
//        control.backgroundColor = Color.random
//
//        control.alpha = 0.3
        
        return control
    }()
    
    
    fileprivate lazy var btn2:UIButton = {
        
        let control = UIButton.init(type: UIButton.ButtonType.custom)
        
        control.addTarget(self, action: #selector(btn2Action), for: UIControl.Event.touchUpInside)
        
//        control.backgroundColor = Color.random
//
//        control.alpha = 0.3
        
        return control
    }()
    
    fileprivate lazy var notiLabel:UILabel = {
        let control = UILabel.init()
        //        control.numberOfLines = 0
        control.textAlignment = .center
//        control.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)
        return control
    }()
    
    
    @objc func btn1Action(){
        
        let vc = ST_BTWebViewController()
        
        vc.urlStr = PH.userProtocolURL
        
        vc.titleStr = "用户协议"
        
        self.parentViewController?.navigationController?.pushViewController(vc)
        
    }
    
    @objc func btn2Action(){
        
        let vc = ST_BTWebViewController()
        
        vc.urlStr = PH.privacyProtocolURL
        
        vc.titleStr = "隐私政策"
        
        self.parentViewController?.navigationController?.pushViewController(vc)
        
    }
}
